package com.tzy.newbank.BankDao;

import com.tzy.newbank.Pojo.Bankuser2;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface MyBankTestDao extends CrudRepository<Bankuser2,Integer> {

    @Query("select b from Bankuser2 b where b.id=?1")
    Bankuser2 findByUserid(Integer userid);

    // 也可以添加一个findById方法，方便使用Optional
    Optional<Bankuser2> findById(Integer id);

    @Query(value="select * FROM bankuser where name=:Name "
            ,nativeQuery = true)
    Bankuser2 findBankuser2BySql(@Param("Name") String custName);

}
